package com.wd.mylibrary_square.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wd.mylibrary_base.bean.AttentionBean
import com.wd.mylibrary_base.bean.ConstellationListBean
import com.wd.mylibrary_base.utils.HttpUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 * 作者: 邢凌志
 * 时间: 2024/9/19
 * 描述:
 */
class ZodiacViewModel : ViewModel() {
    //星座匹配
    var constellationData=MutableLiveData<ConstellationListBean>()

    //关注
    var attentionData=MutableLiveData<AttentionBean>()

    //取消关注
    var cancelAttentionData=MutableLiveData<AttentionBean>()

    fun getConstellationData(userId:Int, sessionId:String, count:Int, maxFriendId:Int){
//        HttpUtils.httpUtils.apiService.getConstellation(userId,sessionId, count, maxFriendId)
//            .subscribeOn(Schedulers.io())
//            .observeOn(AndroidSchedulers.mainThread())
//            .subscribe {
//                constellationData.value=it
//            }
        viewModelScope.launch(Dispatchers.IO) {
            HttpUtils.httpUtils.apiService.getConstellation(userId,sessionId, count, maxFriendId)
        }
    }

    fun getAttentionData(userId:Int, sessionId:String, friend:String){
//        HttpUtils.httpUtils.apiService.getAttention(userId,sessionId,friend)
//            .subscribeOn(Schedulers.io())
//            .observeOn(AndroidSchedulers.mainThread())
//            .subscribe {
//                attentionData.value=it
//            }
        viewModelScope.launch(Dispatchers.IO) {
            HttpUtils.httpUtils.apiService.getAttention(userId,sessionId,friend)
        }
    }

    fun getCancelAttentionData(userId:Int, sessionId:String, friend:Int){
        viewModelScope.launch(Dispatchers.IO) {
            HttpUtils.httpUtils.apiService.getCancelAttention(userId,sessionId,friend)
        }
//        HttpUtils.httpUtils.apiService.getCancelAttention(userId,sessionId,friend)
//            .subscribeOn(Schedulers.io())
//            .observeOn(AndroidSchedulers.mainThread())
//            .subscribe {
//                cancelAttentionData.value=it
//            }
    }

}